/*
 * inter_chip.h
 *
 *  Created on: Oct 1, 2013
 *      Author: Ken Arok
 */

/* Interchip Communication Protocol.
 *
 * Description:
 * This protocol describe communication handshake between ATmega128 chip
 * and ATmega162 on ADO Board. ATmega128 is always as a master whereas ATMega162
 * is always as a slave.
 *
 * Protocol:
 *
 * 1. Polling data is not exist.
 *
 * 		Master	:	|SOH|CMD|ENQ|
 * 		----------------------------------------------------------------------------> time
 * 		Slave	:							|EOT|
 *
 * 2. Polling data is exist.
 *
 * 		Master	:	|SOH|CMD|ENQ|						|ACK|
 * 		----------------------------------------------------------------------------> time
 * 		Slave	:					|STX|TEXT|ETX|BCC|			|EOT|
 *
 * 3. Selecting data (Slave is ready to receive).
 *
 * 		Master	:	|SOH|CMD|ENQ|			|STX|TEXT|ETX|BCC|			|EOT|
 * 		----------------------------------------------------------------------------> time
 * 		Slave	:					|ACK|						|ACK|
 *
 * 4. Selecting data (Slave is not ready to receive).
 *
 * 		Master	:	|SOH|CMD|ENQ|
 * 		----------------------------------------------------------------------------> time
 * 		Slave	:							|EOT|
 */

#ifndef INTER_CHIP_H_
#define INTER_CHIP_H_


typedef struct {
	uint8_t cmd;
	void *pBuf;
} inter_chip_t;

extern void vADO_InterChipInit(void);
extern bool vADO_CommandIsReceived(void);
extern bool vADO_MessageIsReceived(void);
extern uint8_t vADO_GetCommand(void);
extern void *vADO_GetMessage(void);
extern uint8_t vADO_Listen(inter_chip_t *_ic_opt);

#endif /* INTER_CHIP_H_ */
